package com.example.dllo.exe.me;

import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.dllo.exe.R;
import com.example.dllo.exe.main.BaseAty;

/**
 * code is far away from bug with the animal protecting
 * <p>
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃永无BUG！  凯哥 祝你一路顺风
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 */
public class SettingAty extends BaseAty implements View.OnClickListener {
    private LinearLayout llcall;
    private TextView textViewshenfen;
    private ImageView imageViewback;
    private RelativeLayout linearLayoutshezhi;
   private LinearLayout linearLayoutxiaoxituisong;
    @Override
    protected int setLayout() {
        return R.layout.settinglayout;
    }

    @Override
    protected void initView() {
        llcall = bindView(R.id.Call_ll);

        imageViewback = bindView(R.id.back_image);
        textViewshenfen = bindView(R.id.me_shenfen);
        linearLayoutshezhi = bindView(R.id.ll_shezhi);
        linearLayoutxiaoxituisong=bindView(R.id.xiaoxituisong);
    }

    @Override
    protected void initData() {
        llcall.setOnClickListener(this);
        imageViewback.setOnClickListener(this);
        textViewshenfen.setOnClickListener(this);
        linearLayoutshezhi.setOnClickListener(this);
        linearLayoutxiaoxituisong.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.Call_ll:
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_CALL);
                Uri uri = Uri.parse("tel:" + "4009992053");
                intent.setData(uri);
                startActivity(intent);
                break;
            case R.id.back_image:
                finish();

                break;
            case R.id.xiaoxituisong:
                Intent intent1=new Intent(SettingAty.this,XiaoxiTuiSong.class);
                startActivity(intent1);
                break;
            case R.id.ll_shezhi:
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                View viewshezhi = LayoutInflater.from(SettingAty.this).inflate(R.layout.meshezhilayout, null);
                builder.setView(viewshezhi);
                builder.setTitle("选择性别");
                final CheckBox checkBoxman = (CheckBox) viewshezhi.findViewById(R.id.checkman);
                final CheckBox checkBoxwoman = (CheckBox) viewshezhi.findViewById(R.id.checkwoman);
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        if (checkBoxman.isChecked() == true) {
                            textViewshenfen.setText("男");

                        } else if (checkBoxwoman.isChecked() == true) {
                            textViewshenfen.setText("女");
                        }

                    }
                });
                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {

                    }
                });

                builder.show();

                break;
        }
    }
}
